package uva;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * 
 * @author shiv
 * Greedy algo, sort array, find max no of buckets needed by counting max repeating element  
 */

public class Greedy_11100 {

	static int[] input;
	public static void main(String[] args) {
		PrintWriter pw = new PrintWriter(System.out);
		Scanner scn = new Scanner(System.in);
		int size = 0;
		int testcase = 0;
		while((size=scn.nextInt())!=0){
			if(testcase !=0)pw.println(" ");
			testcase++;
			input = new int[size];
			for(int i=0; i<size; i++){
				input[i] = scn.nextInt();
			}

			boolean[] isSel = new boolean[size];
			Arrays.sort(input);
			int noOfBuckets = 1;
			int tempBuck = 1;
			for(int i=1; i<size; i++){
				if(input[i]== input[i-1])tempBuck++;
				else {
					noOfBuckets = Math.max(tempBuck, noOfBuckets);
					tempBuck = 1;
				}
			}
			noOfBuckets = Math.max(tempBuck, noOfBuckets);
			List<StringBuilder> res = new ArrayList(noOfBuckets);
			for(int i=0; i<noOfBuckets; i++){
				res.add(new StringBuilder());
			}
			int cur = 0;
			for(int i=0; i<size; i++){
				StringBuilder sb = null;
				sb = res.get(cur);
				if(++cur >=noOfBuckets) cur = 0;
				sb.append(input[i]).append(" ");
			}
			pw.println(res.size());
			for(StringBuilder str : res){
				pw.println(str.toString().trim());
			}
		}
		pw.close();


	}


}
